using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BardsTaleViewer {
  public partial class ProgressBarControl : UserControl {
    Control _parent;

    public ProgressBarControl (Control parent) {
      InitializeComponent ();

      _parent = parent;
      if (_parent != null)
        _parent.Controls.Add (this);
      SetSizeAndLocation ();
      BringToFront ();
    }

    private void SetSizeAndLocation () {
      // size
      int width = 158;
      int textTotalWidth = _stateUI.Width + 3 + 3;
      if (textTotalWidth > width)
        width = textTotalWidth;
      Width = width;
      //_stateUI.Left = (Width - _stateUI.Width) / 2;

      // location
      if (_parent != null) {
        Left = (_parent.Width - Width) / 2;
        Top = (_parent.Height - Height) / 2;
      }
    }

    public string State {
      set {
        _stateUI.Text = value;
        SetSizeAndLocation ();
      }
    }

    public int Progress {
      set {
        _progressBarUI.Value = value;
      }
    }
  }
}
